package com.example.doctor.jpa;

import com.example.common.entity.DoctorNotice;
import org.springframework.data.repository.query.Param;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface DoctorNoticeRepository extends JpaRepository<DoctorNotice,Long> {

    @Query(value = "SELECT * FROM doctor_notice WHERE dc_id_bigint =:dcId ORDER BY create_time_datetime DESC limit :skip,:limit",nativeQuery = true)
    List<DoctorNotice> list(@Param("dcId") Long dcId ,@Param("skip") Integer skip,@Param("limit") Integer limit);

    @Query(value = "SELECT count(*) FROM doctor_notice WHERE dc_id_bigint =:dcId ",nativeQuery = true)
    long count(@Param("dcId") Long dcId);

    @Query(value = "SELECT * FROM doctor_notice WHERE dc_id_bigint =:dcId ORDER BY create_time_datetime DESC LIMIT 1",nativeQuery = true)
    DoctorNotice findNoticeByDcid(@Param("dcId") Long dcId);
}
